package com.yang.demo.activity;

import android.animation.Animator;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.jaeger.library.StatusBarUtil;
import com.yang.demo.ActivityCollector;
import com.yang.demo.Constant;
import com.yang.demo.MainActivity;
import com.yang.demo.R;
import com.yang.demo.util.rxbus.RxBus;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by yangwenwen on 2018/4/1.
 */
public class ResultActivity2 extends AppCompatActivity {

    @BindView(R.id.rl_bg)
    RelativeLayout bg;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.tv_username)
    TextView tvName;

    private int index = 0;

    Integer[] images = new Integer[]{R.drawable.bg2, R.drawable.bg3, R.drawable.bg4};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result2_activity);
        ButterKnife.bind(this);
        Random random = new Random();
        int i = random.nextInt(images.length);

        bg.setBackground(ContextCompat.getDrawable(this, images[i]));
        ActivityCollector.addActivity(this);
        ButterKnife.bind(this);
        RxBus.get().register(this);
        StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.main_blue), 50);
        StatusBarUtil.setDarkMode(this);


        String type = "";
        //由最初记录的主题来进行判断人格类型
        switch (Constant.theme) {
            case "剧情":
                type = "A";
                break;
            case "动作":
                type = "B";
                break;
            case "爱情":
                type = "C";
                break;
            case "惊悚":
                type = "D";
                break;
            case "悬疑":
                type = "E";
                break;
            case "科幻":

                type = "F";
                break;
            case "战争":
                type = "G";

                break;
            case "古装":
                type = "H";

                break;
        }
        tvName.setText(Constant.username);
        //设置数据
        tvContent.setText("你尝尝热衷于观看" + Constant.theme + "类的电影，欣赏" + MainActivity.clickDirector
                + "导演的作品风格，你可能还会喜欢他的作品《"+Constant.MOVIE+"》。\n\n斯人若彩虹，遇上方知有。而唯独属于你的电影人格是" + type + "型。");

    }

    @OnClick(R.id.iv_back)
    void back() {
        //点击返回键回到主页
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();

    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        //点击返回键回到主页
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            MainActivity.instance.finish();
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
            finish();
        }
        return false;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        RxBus.get().unRegister(this);
    }

    public void onViewClicked() {
    }


}